# 下载器
import requests
class HtmlDownloader(object):
    def download(self,url):
        assert url is not None, "download()方法参数url不能为None"
        # if url is None:
        #     任意选一个
            # raise Exception("url参数不能为None")
            # return None

        headers = {
            'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36',
            'Referer': 'https://baike.baidu.com'
        }
        response = requests.get(url,headers=headers)
        if response.status_code !=200:
            raise Exception(f'请求失败,code{response.status_code}')
        return response.content.decode(encoding='utf-8')
